#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int i = 0;
    int j = 0;
    int arr1[100][100] = { 0 };
    int arr2[100][100] = { 0 };
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d ", &arr1[i][j]);
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d ", &arr2[i][j]);
        }
    }
    float ret = 0;
    float count = 0;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            if (arr1[i][j] == arr2[i][j])
            {
                count++;
            }
        }
    }
    ret = (count * 100) / (n * m);
    printf("%.2f\n", ret);
    return 0;
}